home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ For TASM / ALIASWIN.PAK / LIBRARY.C < prev    next >
C/C++ Source or Header  |  1996-02-21  |  2KB  |  76 lines

  1. /*
  2.    library.c
  3.  
  4.    Copyright (c) 1993 by Borland International, Inc.
  5.  
  6.    This module will become part of library.lib
  7.  
  8.    Part of the aliaswin example.
  9.  
  10.    Build using the provided makefile using:
  11.      "make -B" or "make -B -DWIN16".
  12.       
  13. */
  14.  
  15. #define  STRICT
  16. #include <windows.h>
  17. #include <string.h>
  18.  
  19. /* Prototypes for functions in library.lib. Compare these prototypes with
  20.    the ones in olduser.c, newuser.c and cppuser.cpp. */
  21.  
  22. void SetCoords( LPARAM lParam );
  23. void DrawHappyFace( HDC hdc );
  24. void PrintMessage( HDC hdc, PSTR WhoIsIt );
  25.  
  26. int nWidth  = 0,
  27.     nHeight = 0;
  28. int x, y;
  29.  
  30. void SetCoords( LPARAM lParam )
  31. {
  32.    /* Sets up the size of the window. */
  33.  
  34.    nWidth  = LOWORD( lParam );
  35.    nHeight = HIWORD( lParam );
  36. }
  37.  
  38. void DrawHappyFace( HDC hdc )
  39. {
  40.    x = nWidth / 4;
  41.    y = nHeight / 4;
  42.  
  43.    /* Draw the face, the two eyes, and the nose. */
  44.  
  45.    Ellipse( hdc, x, y, x*3, y*3 );
  46.    Ellipse( hdc, x*3/2-x/8, y*3/2-y/8, x*3/2+x/8, y*3/2+y/8 );
  47.    Ellipse( hdc, x*5/2-x/8, y*3/2-y/8, x*5/2+x/8, y*3/2+y/8 );
  48.    Ellipse( hdc, x*2-x/12, y*2-y/12, x*2+x/12, y*2+y/12 );
  49.  
  50.    /* Draw the mouth. */
  51.  
  52.    Arc( hdc, x*3/2, y*2, x*5/2, y*2.75, x*3/2, y*5/2, x*5/2, y*5/2 );
  53. }
  54.  
  55. void PrintMessage( HDC hdc, PSTR WhoIsIt )
  56. {
  57.    char SomeWords[100] = "Hello from the library to ";
  58.    SIZE strsize;
  59.    int str_x,str_y;
  60.  
  61.    /* Make the final string. Size it, and print it out centered. */
  62.  
  63.    strcat( SomeWords, WhoIsIt );
  64.    GetTextExtentPoint( hdc, SomeWords, strlen( SomeWords ), &strsize );
  65.    if( nWidth < strsize.cx )
  66.       str_x = 0;
  67.    else
  68.       str_x = ( nWidth - strsize.cx ) / 2;
  69.    str_y = y*3.5;
  70.    SetTextAlign( hdc, TA_BASELINE );
  71.    TextOut( hdc, str_x, str_y, SomeWords, strlen( SomeWords ) );
  72. }
  73.  
  74.  
  75.  
  76.